package com.example.javatwo.service.xs.zqy;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.javatwo.mapper.xs.zqy.YsMapper;
import com.example.javatwo.pojo.xs.zqy.PageBean;
import com.example.javatwo.pojo.xs.zqy.paymentdetailed1;
import com.example.javatwo.pojo.xs.zqy.paymentmain;

@Service
public class Ysservice {
	
	@Autowired
	private YsMapper ysmapper;
	
	public List<paymentmain> findYszhu(int currentPage){
		List<paymentmain> list=this.ysmapper.findYszhu(currentPage);
		paymentmain payment=new paymentmain();
		for (paymentmain main : list) {
			payment.setPayment1(this.ysmapper.findYsXiang(main.getFundbillno()));
		}
		list.add(payment);
		return list;
	}
	
	public int findzong(){
		return this.ysmapper.findzong();
	}
	//新增
	public void insertzhu(paymentmain paymentmain){
		this.ysmapper.insertzhu(paymentmain);
		for (paymentdetailed1 xiang: paymentmain.getPayment1()) {
			xiang.setFundbillno(paymentmain.getFundbillno());
			this.ysmapper.insertxiang(xiang);
		}
	}
	
	//修改
		public void update(paymentmain paymentmain){
			this.ysmapper.delzhu(paymentmain.getFundbillno());
			this.ysmapper.insertzhu(paymentmain);
			this.ysmapper.delxiang(paymentmain.getFundbillno());
			for (paymentdetailed1 xiang: paymentmain.getPayment1()) {
				xiang.setFundbillno(paymentmain.getFundbillno());
				this.ysmapper.insertxiang(xiang);
			}
		}
		
	//删除
		public void del(String fundbillno){
			this.ysmapper.delzhu(fundbillno);
			this.ysmapper.delxiang(fundbillno);

		}
}
